<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>任务版本号管理 | 任务版本号列表</title>
<@fm.header />
<script>
function doSearch(){    
    $('#tt').datagrid('load', {
        isUseful : $('#isUseful').combobox('getValue'),
        sysVer:$('#sysVer').combobox('getValue')
    });
}
function add(){
    showMyWindow('任务版本号管理 | 新建任务版本号', '/taskver/add', 400, 350);
}
function edit(){
	var row = $('#tt').datagrid('getSelected');
    if (row){
	    showMyWindow('任务版本号管理 | 编辑任务版本号', '/taskver/'+row.ver+'/update', 400, 350);
    } else {
    	showMsg(market.content.title, market.content.tips, alert);
    }
}

function channgeStatus(value) {
    var row = $('#tt').datagrid('getSelected');
    $.messager.confirm('温馨提醒', '你确定操作吗？', function(r) {
        if (r) {
            $.get('/taskver/changeStatus?id=' + row.id +"&isUseful="+value, function(data) {
                if (data.return_code == '1') {
                    top.showMsg(market.content.title, data.return_msg, alert);
                    doSearch();
                } else if (data.return_code == '3') {
                    top.showMsg(market.content.title, data.return_msg, alert);
                } else {
                    $.messager.alert(market.content.title, data.return_msg);
                }
            });
        }
    });
}

</script>
</head>
<body class="cmp-list-body">
<div id="tb" style="padding:3px">
    <span>版本号:</span>

    <input id="sysVer" class="easyui-combobox" style="width: 155px;" name="sysVer" data-options="
		url:'/sysver/list?isUseful=1&json',
		method:'get',
		valueField:'ver',
		textField:'ver'" />

    <span>状态:</span>
    <select class="easyui-combobox" id="isUseful" panelHeight="auto" style="width:155px" >
        <option value="-1" selected>-选择-</option>
        <option value="1" selected>启用</option>
        <option value="0">废弃</option>
    </select>
    <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="doSearch();">查询</a> 
    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="channgeStatus(0);">作废</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="channgeStatus(1);">启用</a>
</div>
<table id="tt" class="easyui-datagrid" title="任务版本号管理 | 任务版本号列表" iconCls="icon-save" 
	url="/taskver/listdata" toolbar="#tb" rownumbers="true" idField="id"
	singleSelect="true" pagination="true" fitColumns="true" pageSize="15" pageList="[15,30,60,80,100]"> 
    <thead>
        <tr>
            <th align="center" width="20%" field="sysVer">任务版本号</th>
            <th align="center" width="20%" field="taskType" formatter="formatterTaskType">任务类型</th>
            <th align="center" width="20%" field="isUseful" formatter="formatterStatus">状态</th>
            <th align="center" width="20%" field="createTime">创建时间</th>
            <th align="center" width="20%" field="modifyTime">更新时间</th>
        </tr>
    </thead>   
</table>

<script>


    $(function() {
        $('#isUseful').combobox("select",-1);
    });

    function formatterTaskType(value) {
        if (value == 1) {
            return "新增";
        }
        if (value == 2) {
            return "留存";
        }

    }

    function formatterStatus(value) {
        if (value == 1) {
            return "启用";
        }
        return "作废";

    }

</script>

</body>
</html>